package com.fu.shop.service.Impl;

import com.fu.core.pojo.User;
import com.fu.core.service.impl.BaseServiceImpl;
import com.fu.shop.mapper.UserMapper;
import com.fu.shop.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 付龙江
 * @date 2022/2/5 11:32
 */
@Service("userService")
public class UserServiceImpl extends BaseServiceImpl<User> implements UserService {

    UserMapper userMapper;

    @Autowired(required = false)
    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    /**
     * 用户信息管理
     *
     * @param userName 姓名
     * @param page 页码
     * @param size 每页长度
     * @return 返回分页后的数据
     */
    @Override
    public PageInfo<Map<String, Object>> selectUserList(String userName, Integer page, Integer size) {
        PageHelper.startPage(page,size);
        List<Map<String, Object>> list = userMapper.selectUserList(userName);
        return PageInfo.of(list);
    }

    /**
     * @return 导出用户信息
     */
    @Override
    public List<Map<String, Object>> uploadUserList() {
        return userMapper.selectUserList(null);
    }
}
